#!/bin/sh

install_mirror() {
	USER=$(whoami)
	if [ ${USER} = root ]; then
		echo "This is run by user ${USER} as expected"
		if [ -f /etc/apt/source.list.d/mirrors.163.com.sources ]; then
			echo "/etc/apt/source.list.d/mirrors.163.com.sources already exists."
		else
			mkdir -p /etc/apt/source.list.d
			cp ./apt/etc/apt/source.list.d/mirrors.163.com.sources /etc/apt/source.list.d/mirrors.163.com.sources 
		fi
	else
		echo "ERROR: This is not run by user root but by ${USER}. Please run it by sudo."
		return 1
	fi
}

install_mirror
